//
//  MyMoneyTableViewController.m
//  明和智能
//
//  Created by 李李善 on 2018/8/23.
//  Copyright © 2018年 inno. All rights reserved.
//

#import "MyMoneyTableViewController.h"
#import "UIBarButtonItem+Extension.h"
#import "MyLiuShuiTableViewController.h"
#import "MZLoginCell.h"
#import "MyMoneyTableViewCell.h"
#import "ZhongZhiTableViewController.h"
@interface MyMoneyTableViewController ()

@end

@implementation MyMoneyTableViewController

- (void)viewDidLoad {
    [super viewDidLoad];
     
    UIBarButtonItem *rightItem = [UIBarButtonItem OnCreateBarBtnItemName:@"收入明细" BarBtnstyle:(RightBarBtnItemStyle) Btntag:10 target:self action:@selector(onRightBtn:)];
    UIButton *button = [rightItem.customView viewWithTag:10];
    button.titleLabel.font = kSysFont(kFitW(12));
    [button setNormalTitleColor:[UIColor whiteColor]];
    self.navigationItem.rightBarButtonItem =rightItem;
    
}
-(void)onLoadViewByWillAppear:(UIView *)view
{
    NSString *s =@"查看会员规则";
    [self.tableView config:^(UITableView *tableView) {
        tableView.backgroundColor = hexCOLOR(@"ECECEC");
        tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
        tableView.tableFooterView = ({
            UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
            button.size = CGSizeMake(kScreenW,kFitH(50));
            //button.backgroundColor = [UIColor redColor];
            [button layoutButtonWithEdgeInsetsStyle:(MKButtonEdgeInsetsStyleLeft) imageTitleSpace:4];
            
            [button setNormalImage:[UIImage imageNamed:@"guize"]];
            NSMutableAttributedString *attributedString = [[NSMutableAttributedString alloc]initWithString:s];
            //颜色
            [attributedString addAttribute:NSForegroundColorAttributeName value:
             [UIColor blackColor] range:NSMakeRange(0,s.length)];
            // 下划线
            [attributedString addAttribute:NSUnderlineStyleAttributeName value:
             [NSNumber numberWithInteger:NSUnderlineStyleSingle] range:NSMakeRange(0,s.length)];
            //大小
            [attributedString addAttribute:NSFontAttributeName value:kSysFont(kFitW(12)) range:NSMakeRange(0,s.length)];
            [button setAttributedTitle:attributedString forState:(UIControlStateNormal)];
            button.tag = 20;
            [button AddTarget:self Action:@selector(onRightBtn:)];
            button;
        });
    }];
}
-(void)onRightBtn:(UIButton *)button
{
    switch (button.tag) {
        case 10:
        {
            MyLiuShuiTableViewController *vc = [MyLiuShuiTableViewController new];
            vc.title = @"收入明细";
            [self pushToVC:vc];
            
        }
            break;
        case 20://查看会员规则
        {
            
            
        }
            break;
        case 30://充值
        {
            ZhongZhiTableViewController *vc = [[ZhongZhiTableViewController alloc]initWithStyle:(UITableViewStyleGrouped)];
            vc.title = @"充值";
            [self pushToVC:vc];
        }
            break;
        default://
        {
            
            
        }
            break;
    }
}

-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return 7;
}
#pragma mark - Table view data source
-(MCCellInfo *)tableView:(UITableView *)tableView cellForIndexPath:(NSIndexPath *)indexPath IsHeight:(BOOL)isheight
{
    
    if (indexPath.row==0) {
        return [MCCellInfo configForCellId:cell Class:[MZLoginCell0 class] Height:kFitH(15) TableView:tableView];
        
    }
    else if (indexPath.row==1)
    {
        return [MCCellInfo configForCellId:cell2 Class:[MyMoneyTableViewCell class] Height:kFitH(60) TableView:tableView CellStyle:(UITableViewCellStyleSubtitle)];
    }
    else if (indexPath.row==2)
    {
    return [MCCellInfo configForCellId:cell3 Class:[MyMoneyTableViewCell1 class] Height:kFitH(120) TableView:tableView];
    }
    else if (indexPath.row==3)
    {
        return [MCCellInfo configForCellId:cell5 Class:[MyMoneyTableViewCell2 class] Height:kFitH(50) TableView:tableView];
    }
    
    return [MCCellInfo configForCellId:cell4 Class:[MyMoneyTableViewCell3 class] Height:kFitH(80) TableView:tableView];
    
    
    
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
